<template>
  <header
    v-windowDrag 
    class="w-header"
    :data-flag="flag"
    @dblclick='handleZoom(value)'>
        <div class="full-w full-h flex-between">
            <div class="flex-center" style="margin-left:10px">

                <div class="left-icon" v-if="value.icon">
                    <img :src="CheckFullUrl(value.icon)" draggable="false" :style="{background:value.background||''}">
                </div>

                <div class="left-icon" v-else>
                    <img :src="value.xIcon" draggable="false" :style="{background:value.background||''}">
                </div>

                <div style="font-size: 15px;margin-bottom: 1px;">
                    {{value.name}}
                </div>
            </div>
            <div>
                <el-icon @click='handleHide(value)' title="最小化"><minus /></el-icon>
                <el-icon @click='handleZoom(value)' title="缩放"><copy-document /></el-icon>
                <el-icon @click='handleClose(value)' title="关闭"><close /></el-icon>
            </div>
        </div>
    </header>
</template>

<script lang='ts'>
import { reactive, toRefs, defineComponent } from 'vue';
import useCheck from '@/hooks/useCheck';
export default defineComponent({
    name:'windowHeader',
    props: {
        value:{
            type:Object,
            default:null
        },
        flag:{
            type:String,
            default:'1'
        }

    },
    components: {

    },
    emits:['zoom',  'close', 'hide'],
    setup (props, context) 
    {

        let data = reactive({});
        let methods = {
            handleZoom (value)
            {
                context.emit('zoom', value);
            },
            handleClose (value)
            {
                context.emit('close', value);
            },
            handleHide (value)
            {
                context.emit('hide', value);
            }
        };
        return { 
            ...toRefs(data),
            ...methods,
            ...useCheck()
        };
    }
});
</script>

<style scoped lang="scss">
.w-header {
    padding: 2px;
    // width: 100%;
    border-radius: 5px;
    height: 30px;
    box-shadow: 0px -2px 8px 7px $ShadowColor;
    margin: 5px;

    .left-icon {
        height: 20px;
        width: 20px;
        min-width: 20px;
        margin-right: 5px;
        border-radius: 3px;
        overflow: hidden;
    }


    i {
        padding: 5px;
        height: 100%;
        width: 30px;
        margin: 0 3px;
        background-color: transparent;
        border-radius: 3px;
        transition: all .3s;
        cursor: pointer;

        &:hover {
            background-color: var(--el-bg-color-folder);
        }
    }
}

.above-box {
    margin-bottom: 5px;
    height: 33px;
}
</style>
